<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>模板选择</title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>
</head>
<body>
<div id="wrapper">
	<div class="curmb"><s:text name="your.site.position"/>:<a href="${ctx}/main.action"><s:text name="homepage"/></a><span>></span><s:text name="theme.file.title"/></div>
	<div class="listtit" id="listtit"><p><span><strong><s:text name="theme.file.list.title"/></strong></span></p></div>
	<div class="searchbox">
	<s:hidden name="selected" id="selected"/>
		<div class="clear"></div>
	</div>
	<div class="listbox" id="listbox">
		<table class="listgrid" id="listbox">
			<tbody>
				<tr>
				<s:if test="elementId=='catContentTplSet'">
					<th><input type="checkbox" name="all" id="all_check"/></th>
				</s:if>
				<s:else>
					<th></th>
				</s:else>
					<th><s:text name="fileName"/></th>
					<th><s:text name="filePath"/></th>
					<th><s:text name="fileSize"/></th>
					<th><s:text name="actionBar"/></th>
					
				</tr>
				<s:if test="elementId=='catContentTplSet'">
					<s:iterator value="fileBeanList">
						<tr>
						<td><input id="<s:property value="%{getStr(path)}"/>" type="checkbox" name="key" value="<s:property value="path"/>"/></td>
						<td><s:property value="name"/>&nbsp;</td>
						<td><s:property value="path"/>&nbsp;</td>
						<td><s:property value="size"/>&nbsp;</td>
						<td><a  href="${ctx}/theme/file-input.action?crruentpath=<s:property value='selectEditPath'/>&selected=<s:property value="selected"/>&<s:property value='selparas'/>"><s:text name="fileEditor"/></a></td>
						</tr>
					</s:iterator>
				</s:if>
				<s:else>
					<s:iterator value="fileBeanList">
						<tr>
						<td><input id="<s:property value="%{getStr(path)}"/>" type="radio" name="key" value="<s:property value="path"/>"/></td>
						<td><s:property value="name"/>&nbsp;</td>
						<td align="left"><s:property value="path"/>&nbsp;</td>
						<td><s:property value="size"/>&nbsp;</td>
						<td><a  href="${ctx}/theme/file-input.action?crruentpath=<s:property value='selectEditPath'/>&selected=<s:property value="selected"/>&<s:property value='selparas'/>"><s:text name="fileEditor"/></a></td>
						</tr>
					</s:iterator>
				</s:else>
				
			</tbody>
		</table>
	</div>
	<div class="listoperateb ">
		<span>
		<s:if test="elementId=='catContentTplSet'">
			<input type="button" value="<s:text name="anti-selection"/>" class="btnlist2" id="bottom_anti_btn"/>
		</s:if>
			<input type="button" value="<s:text name="determine"/>" class="btnlist2" id="ok" />
			<input type="button" value="<s:text name="cancleDo"/>" class="btnlist2" id="no"/>
		</span>
	</div>
</div>
</body>
</html>
<script src="${ctx}/js/jquery.form.js" type="text/javascript"></script>
<script type="text/javascript" defer="defer">
	$(function(){
 		$("#bottom_anti_btn").click(antiSelect);
		$("#all_check").click(selAll);
 		$("#ok").click(getAllIds);
 		$("#no").click(cancelButton);
 		
 		// 回显已经选中的模板
 		var selectedVal = $("#selected").val();
 		var selectedVal1 = selectedVal.replace(/\//g,"");
 	    var selectedVal2 = selectedVal1.replace(/\./g, "");
 	    var selectList = selectedVal2.split("-");
 	    for(var i=0;i<selectedVal2.length;i++){
 	    	$("#"+selectList[i]).attr("checked",true);
 	    }
	});
 
	function getAllIds(){
		var arr = new Array();
		$("input[name='key']:checked").each(function(i,item){
			arr.push($(item).val());
		});
		var path =arr.join('-');
		if(path){			
			opener.document.getElementById("<s:property value="elementId"/>").value=path;
			window.close();
		}else{
			alert("请选择");
		}
	}
	
	function cancelButton(){
		window.close();
	}
	
	//测试用
	function inSelectPage(){
		window.open("${ctx}/theme/file-select.action?type=index&prefix=index&suffix=tpl&elementId=123456789");
	} 
 
	
	</script>